package com.maker.generator.entity;

import java.io.Serializable;

import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;

import com.dwork.base.validate.groups.ADD;
import com.dwork.base.validate.groups.DEFAULT;
/**
 * 元对象的属性
 * @author rainbow
 *
 */
public class MetaGenAttr implements Serializable{
	
	private static final long serialVersionUID = -2436737075419725099L;
	
	public static final String RELATIONSHIP = "relationShip";
	
	public static final String RELATIONSHIP_1N = "1:N";
	public static final String RELATIONSHIP_NN = "N:N";
	public static final String RELATIONSHIP_N1 = "N:1";
	
	public static final String RELATIONTYPE = "relationType";
	
	public static final String RELATIONTYPE_LIST = "List";
	public static final String RELATIONTYPE_SET = "Set";
	
	
	
	public static final String CFG_KEY_COMMENT = "attr_comment";
	public static final String CFG_KEY_VALIDATES = "attr_validates";
	
	
	private Long id;
	/**
	 * 元属性所属的元对象
	 */
	private MetaGenObj metaObj;

	/**
	 * 元字段名
	 */
	@NotEmpty(message="{metaGenAttr.attrName.notempty}", groups={DEFAULT.class,ADD.class})
	@Length(min=2, max=50,message="{metaGenAttr.attrName.length}", groups={DEFAULT.class,ADD.class})
	private String attrName;
	/**
	 * 元字段完整类型，主要用于生成引用对象；
	 */
	@NotEmpty(message="{metaGenAttr.attrType.notempty}", groups={DEFAULT.class,ADD.class})
	private String attrType;
	/**
	 * 元字段类型简写,主要用于生成逻辑代码中；
	 */
	@NotEmpty(message="{metaGenAttr.attrShortTypeName.notempty}", groups={DEFAULT.class,ADD.class})
	private String attrShortTypeName;
	/**
	 * 备注
	 */
	private String attrComment;
	/**
	 * 是否属于基础类型
	 */
	private Boolean isBaseType;
	/**
	 * 对应关系，元对象 与 元属性对象的对应关系：1:N，N:N，N:1
	 */
	private String relationShip;
	/**
	 * 对应的类型，默认情况下是List,但可以接定为Set等。
	 */
	private String relationType;
	/**
	 * 此属性是非技久化属性。
	 * 如果是对应关系，引用哪个元对象。适用于多对一的一方，一对多的多方，多对多的多方。
	 * 用于生成MAPP时，获取引用的元对象，并获取其引用的元对象的属性列表，用以建好映射。
	 */
	private MetaGenObj metaRefObj;
	
	/**
	 * 配置
	 */
	private MetaGenConfig config;
	
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public MetaGenObj getMetaObj() {
		return metaObj;
	}
	public void setMetaObj(MetaGenObj metaObj) {
		this.metaObj = metaObj;
	}
	public String getAttrName() {
		return attrName;
	}
	public void setAttrName(String attrName) {
		this.attrName = attrName;
	}
	public String getAttrType() {
		return attrType;
	}
	public void setAttrType(String attrType) {
		this.attrType = attrType;
	}
	public String getAttrShortTypeName() {
		return attrShortTypeName;
	}
	public void setAttrShortTypeName(String attrShortTypeName) {
		this.attrShortTypeName = attrShortTypeName;
	}
	public String getAttrComment() {
		return attrComment;
	}
	public void setAttrComment(String attrComment) {
		this.attrComment = attrComment;
	}
	public Boolean getIsBaseType() {
		return isBaseType;
	}
	public void setIsBaseType(Boolean isBaseType) {
		this.isBaseType = isBaseType;
	}
	
	public String getRelationShip() {
		if(this.relationShip == null){
			return "";
		}
		return relationShip;
	}
	public void setRelationShip(String relationShip) {
		this.relationShip = relationShip;
	}
	public String getRelationType() {
		return relationType;
	}
	public void setRelationType(String relationType) {
		this.relationType = relationType;
	}
	public MetaGenConfig getConfig() {
		return config;
	}
	public void setConfig(MetaGenConfig config) {
		this.config = config;
	}
	public MetaGenObj getMetaRefObj() {
		return metaRefObj;
	}
	public void setMetaRefObj(MetaGenObj metaRefObj) {
		this.metaRefObj = metaRefObj;
	}
	
	
	
	
	

}
